<template>
  <div>
    <el-menu
      :default-active="path"
      class="el-menu-demo"
      mode="horizontal"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      router
    >
      <el-menu-item index="1">首页</el-menu-item>
      <el-submenu index="2">
        <template slot="title">我的组件库</template>
        <el-menu-item index="/indexForm">拖拽表单组件</el-menu-item>
        <el-menu-item index="/diyForm">自定义表单组件</el-menu-item>
        <el-menu-item index="/table">table组件</el-menu-item>
      </el-submenu>
      <el-menu-item index="3">更多扩展</el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeIndex: "1",
      path: "",
      //   菜单列表
      menuList: [
        {
          name: "首页",
          children: [
            {
              name: "待开发",
              path: "/",
            },
          ],
          url: "/",
        },
        {
          name: "我的组件库",
          children: [
            {
              name: "拖拽自定义表单",
              path: "/newDraggable",
            },
          ],
          url: "",
        },
      ],
    };
  },
  created() {
    this.onRouteChanged();
  },
  methods: {
    onRouteChanged() {
      let that = this;
      that.path = that.$route.path;
    },
  },
};
